package com.sk.sourcecircle.dialog;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.sk.sourcecircle.R;
import com.sk.sourcecircle.base.BaseDialogFragment;
import com.sk.sourcecircle.callback.BuyCallback;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * Created by sk on 2018/1/23.
 */

public class BuyTipDialogFragment extends BaseDialogFragment {
    @BindView(R.id.tv_tip)
    TextView tvTip;
    @BindView(R.id.cancel)
    TextView cancel;
    @BindView(R.id.sure)
    TextView sure;
    Unbinder unbinder;

    private BuyCallback buyCallback;

    public BuyCallback getBuyCallback() {
        return buyCallback;
    }

    public void setBuyCallback(BuyCallback buyCallback) {
        this.buyCallback = buyCallback;
    }

    @Override
    protected int getContentView() {
        return R.layout.bug_tip_dialog;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick({R.id.cancel, R.id.sure})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.cancel:
                dismiss();
                break;
            case R.id.sure:
                dismiss();
                if (buyCallback != null) {
                    buyCallback.sureBuy();
                }
                break;
        }
    }
}
